import request from './request'
export function uploadProfile(profile: File) {
  return request({
    method: 'patch',
    url: '/user/changeProfile',
    data: {
      fileToUpload: profile
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
export function updateMail(newMail: string, code: string) {
  return request({
    method: 'patch',
    url: 'user/updateMail',
    data: {
      newMail: newMail,
      mailVerificationCode: code
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
export function getUserInfo() {
  return request({
    method: 'get',
    url: '/user/getUserInfo'
  })
}

export function updateAppointedUser(id: number, x: string, y: string, z: string, flag: boolean) {
  let dataToSend = {}
  if (flag) {
    //学生
    dataToSend = {
      id: id,
      number: x,
      academy: y,
      politics: z
    }
  } else {
    //教师
    dataToSend = {
      id: id,
      researchDirection: x,
      academy: y,
      politics: z
    }
  }
  return request({
    method: 'patch',
    url: '/user/updateAppointedUser',
    headers: {
      'Content-Type': 'application/json'
    },
    data: JSON.stringify(dataToSend)
  })
}
//获取评价信息
export function getEstimation() {
  return request({
    method: 'get',
    url: 'user/getEvaluated'
  })
}
//获取待评价的人
export function getToEstimation() {
  return request({
    method: 'get',
    url: 'user/getToEvaluate'
  })
}
//评价
export function estimate(id: number, moral: number, attitude: number, practice: number) {
  return request({
    method: 'post',
    url: 'user/evaluate',
    params: {
      evaluateId: id,
      moral: moral,
      attitude: attitude,
      practice: practice
    }
  })
}
